<template>
	<view class="ry-items-con">
		<view class="ry-item" @click="itemClick(item)" v-for="(item,index) in list" :key="index"
			:style="{'background':bgColor}">
			<view class="title">
				{{item.store_name}}
			</view>
			<view class="top">
				<image :src="item.goods_img" class="left-img"></image>
				<view class="right">
					<view class="tit">{{item.goods_name}}</view>
					<view class="line-progress">
						<view class="line-bg" :style="{'width':item.take_bili+'%'}"></view>
						<view class="line-text">已抢{{item.take_bili}}%</view>
					</view>
					<view class="right-bot">
						<view class="right-bot-item">
							<view class="right-bot-item-tit">周期</view>
							<view class="right-bot-item-desc">{{item.sy_day}}天</view>
						</view>
						<view class="right-bot-item">
							<view class="right-bot-item-tit">产重</view>
							<view class="right-bot-item-desc">{{item.yield}}斤</view>
						</view>
						<view class="right-bot-item">
							<view class="right-bot-item-tit">日收益</view>
							<view class="right-bot-item-desc">{{item.day_sy}}两</view>
						</view>
					</view>
				</view>
			</view>
			<view class="center">
				<text>¥</text>
				<text class="price">{{item.goods_price}}</text>
				<text>元</text>
				<text>/{{item.unit}}</text>
			</view>
			<view class="bot">
				<view class="left">
					<view class="avatar-group" v-if="item.head_urls.length>0">
						<u-avatar-group :urls="item.head_urls" size="35" gap="0.5"></u-avatar-group>
					</view>
					<text>已有{{item.take_num}}人参与</text>
				</view>
				<button size="mini" class="ry-btn" @click.stop="btnClick(item)">认养</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-ry-items",
		props: {
			list: {
				type: Array,
				default: () => []
			},
			bgColor: {
				type: String,
				default: 'transparent'
			},
		},
		data() {
			return {
				urls: [
					'https://cdn.uviewui.com/uview/album/1.jpg',
					'https://cdn.uviewui.com/uview/album/2.jpg',
					'https://cdn.uviewui.com/uview/album/3.jpg',
				],
			};
		},
		methods: {
			itemClick(item) {
				this.$emit('itemClick', item)
			},
			btnClick(item) {
				this.$emit('btnClick', item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ry-items-con {
		padding: 0 30rpx;

		.ry-item {
			border-radius: 20rpx;
			box-shadow: $global-shade;
			padding: 30rpx;

			.title {
				padding: 10rpx 0 20rpx;
				border-bottom: 1px solid #ddd;
				margin-bottom: 20rpx;
				font-size: 30rpx;
				font-weight: 600;
			}

			&:not(:last-child) {
				margin-bottom: 20rpx;
			}

			.top {
				@include flex-box();
				border-bottom: $global-border;
				padding-bottom: 30rpx;

				.left-img {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}

				.right {
					flex: 1;
					@include flex-box(column, space-around);

					.tit {
						font-weight: 500;
						font-size: 30rpx;
					}

					.line-progress {
						position: relative;
						background: $bg-F7F7F7;
						height: 30rpx;
						border-radius: 30rpx;
						overflow: hidden;

						.line-bg {
							position: absolute;
							left: 0;
							top: 0;
							height: 100%;
							background: $theme-color;
							width: 30%;
						}

						.line-text {
							height: 100%;
							width: 100%;
							color: $color-919191;
							text-align: center;
							position: absolute;
							left: 0;
							top: 0;
							font-size: 22rpx;
						}
					}

					.right-bot {
						@include flex-box(row, space-between);

						.right-bot-item {
							.right-bot-item-tit {
								color: $color-919191;
							}

							.right-bot-item-desc {
								text-align: center;
							}
						}
					}
				}
			}

			.center {
				@include flex-center();
				height: 70rpx;

				text {
					color: $theme-F94A36;

					&:last-child {
						color: $color-080524;
					}
				}

				.price {
					font-size: 36rpx;
				}
			}

			.bot {
				@include flex-box(row, space-between, center);

				.left {
					@include flex-center();

					.avatar-group {
						margin-right: 10rpx;
					}

					text {}
				}

				.ry-btn {
					background: $theme-color;
					color: #fff;
					min-width: 160rpx;
					line-height: 60rpx;
					height: 60rpx;
					border-radius: 40rpx;
					font-size: 28rpx;
				}
			}
		}
	}
</style>